package org.road0329.tools.proto_parse_tool.enums;

/**
 * 表码类型
 * 
 * @author 30009521
 */
public enum BmTypeEnum{
                        BM_ZY(1, "正向有功"), BM_ZW(2, "正向无功"), BM_FY(3, "反向有功"), BM_FW(4, "反向无功"), BM_ZHY(54, "组合有功表码"), BM_ZHW(55, "组合无功表码");

    private final int    value;
    private final String text;

    private BmTypeEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }

    public int getValue() {
        return value;
    }

    public Short getShortValue() {
        return Short.valueOf(value+"");
    }

    public String getText() {
        return text;
    }

    public static String getText(int value) {
        BmTypeEnum task = getEnmuByValue(value);
        return task == null ? "" : task.getText();

    }

    /**
     * 通过传入的字符串匹配枚举，传入值
     * 
     * @param value
     * @return
     */
    public static BmTypeEnum getEnmuByValue(int value) {
        for (BmTypeEnum bmType : BmTypeEnum.values()) {
            if (value == bmType.getValue()) {
                return bmType;
            }
        }
        return null;
    }
}
